package com.zscat.beetl.function;

import java.util.List;

import javax.annotation.Resource;

import com.alibaba.dubbo.config.annotation.DubboConsumer;
import com.zscat.goods.model.Product;
import com.zscat.goods.model.ProductClass;
import com.zscat.util.MemberUtils;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.zscat.conf.JbaseFunctionPackage;
import com.zscat.goods.service.ProductClassService;
import com.zscat.goods.service.CartService;
import com.zscat.goods.service.FloorService;
import com.zscat.goods.service.ProductService;
import com.zscat.member.service.MemberService;
import com.zscat.order.service.OrderService;


@Service("productClass")
public class ProductClassFunctions implements JbaseFunctionPackage {
    @DubboConsumer
    private ProductClassService goodsClassService;
    //	@Resource
//	private ShopTypeService ShopTypeService;
    @DubboConsumer
    private ProductService ProductService;
    @DubboConsumer
    private CartService CartService;

    public List<ProductClass> getProductClassListByPid(Long pid) {
        ProductClass gc = new ProductClass();
        gc.setParentId(pid);
        return goodsClassService.select(gc);
    }
//	public List<ShopType> getShopTypeListByPid(Long pid){
//		ShopType gc=new ShopType();
//		gc.setParentId(pid);
//		return ShopTypeService.select(gc);
//	}

    /**
     * 根据商品类型查询商品
     *
     * @param tid
     * @return
     */
    public List<Product> getProductListByTypeid(Long tid) {
        Product goods = new Product();
        goods.setType(tid);
        return ProductService.selectPage(1, 6, goods).getList();
    }

    /**
     * 查询楼层商品
     *
     * @param tid
     * @return
     */
    public List<Product> getProductByFloorid(Long tid) {
        return ProductService.selectProductByFloor(tid);
    }
    /**
     * 根据订单查询商品
     * @param tid
     * @return
     */
//	public List<Product> getProductListByOrderid(Long tid){
//		Product goods=new Product();
//		
//		return ProductService.selectPage(1, 6, goods).getList();
//	}

    /**
     * 得到购物车数量
     *
     * @return
     */
    public int selectOwnCartCount() {
        if (MemberUtils.getSessionLoginUser()!=null){
            return CartService.selectOwnCartCount(MemberUtils.getSessionLoginUser().getId());
        }
       return 0;
    }
}
